package org.lib093.ndkapplication;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import org.fmod.FMOD;

// TODO 终点：本节课目标：Android NDK 导入 C库，开发流程，一劳永逸，任何C库 都是一样的 非常慢
public class MainActivity extends AppCompatActivity implements VoiceManager.PlayListener {

    String path;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        path =  "file:///android_asset/derry.mp3";
     //   ((TextView)findViewById(R.id.txt)).setText( VoiceManager.Companion.getInstance(this). stringFromJNI());
        VoiceManager.Companion.getInstance(this).init().setListener(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        VoiceManager.Companion.getInstance(this).close();
    }

    // 六个 点击事件
    public void onFix(View view) {
        switch (view.getId()) {
            case R.id.btn_normal:
                VoiceManager.Companion.getInstance(this). voiceChangeNative(VoiceManager.MODE_NORMAL, path); // 真实开发中，必须子线程  JNI线程（很多坑）
                break;
            case R.id.btn_luoli:
                VoiceManager.Companion.getInstance(this). voiceChangeNative(VoiceManager.MODE_LUOLI, path);
                break;
            case R.id.btn_dashu:
                VoiceManager.Companion.getInstance(this). voiceChangeNative(VoiceManager.MODE_DASHU, path);
                break;
            case R.id.btn_jingsong:
                VoiceManager.Companion.getInstance(this). voiceChangeNative(VoiceManager.MODE_JINGSONG, path);
                break;
            case R.id.btn_gaoguai:
                VoiceManager.Companion.getInstance(this). voiceChangeNative(VoiceManager.MODE_GAOGUAI, path);
                break;
            case R.id.btn_kongling:
                VoiceManager.Companion.getInstance(this).  voiceChangeNative(VoiceManager.MODE_KONGLING, path);
                break;
        }
    }

    @Override
    public void start() {
        super.onStart();
        Toast.makeText(App.innstance, "播放开始", Toast.LENGTH_LONG).show();
    }

    @Override
    public void finish() {
        Toast.makeText(App.innstance,"播放结束",Toast.LENGTH_LONG).show();
    }
}
